<template>
  <s-layout
    :title="state.type==='1'?'代理公司入驻':'公司入驻'"
    :bgStyle="{
      color: '#FFFFFF',
    }"
  >
    <template>
      <view class="status" v-if="state.status !== null">
        <view class="status-top ss-p-l-50">
          <!-- 等待审核 -->
          <view
            class="status-wait ss-flex align-center"
            v-if="state.status === 0"
          >
            <image
              class="status-wait-image ss-m-r-30"
              src="https://liuliangbenben.oss-cn-hangzhou.aliyuncs.com/storage/ugc/20250326/135823c277d6aa8f2260e3451a462e9e.png"
            >
            </image>

            <view class="flex" style="display: flex; justify-content: start; align-items: center">
              <view v-if="state.form.sigin_link == null" class="status-wait-title">提交成功</view>
              <view v-if="state.form.sigin_link != null" class="status-wait-title"
                >初审成功，等待签约</view
              >
            </view>
          </view>
          <!-- 审核成功 -->
          <view class="status-wait ss-flex align-center" v-if="state.status === 1">
            <image
              class="status-wait-image ss-m-r-30"
              src="https://liuliangbenben.oss-cn-hangzhou.aliyuncs.com/storage/ugc/20250326/135823c277d6aa8f2260e3451a462e9e.png"
            >
            </image>
            <view>
              <view class="status-wait-title">审核成功</view>
            </view>
          </view>

          <!-- 审核失败 -->
          <view class="status-wait ss-flex align-center" v-if="state.status === 2">
            <image
              class="status-wait-image ss-m-r-30"
              src="https://liuliangbenben.oss-cn-hangzhou.aliyuncs.com/storage/ugc/20250326/926e5911ce12a3389b0296efd3929b3f.png"
            >
            </image>
            <view>
              <view class="status-wait-title">审核失败</view>
              <view class="status-wait-tips ss-m-t-10">失败原因：{{ state.form.remark }}</view>
            </view>
          </view>
          <!-- 已解除合作 -->
          <!-- <view class="status-wait ss-flex align-center" v-if="state.status < 0">
            <image
              class="status-wait-image ss-m-r-30"
              src="https://liuliangbenben.oss-cn-hangzhou.aliyuncs.com/storage/ugc/20250326/926e5911ce12a3389b0296efd3929b3f.png"
            >
            </image>
            <view>
              <view class="status-wait-title">已解除合作</view>
            </view>
          </view> -->
        </view>
        <view class="status-bottom"></view>
      </view>
	  
	  <!-- //////////////////////////////////////////////////////////////////////////////////////////////// -->
      <view class="form">
		  <!-- 代办人信息模块 -->
		  <template v-if="state.type=='1'||state.id">
			  <view class="form-title"> 邀请人信息 </view>
			   <view class="form-item ss-flex justify-between align-center b-b-c">
			     <view class="form-label"> <text>*</text>邀请人类型 </view>
			     <input
			       class="form-input"
			       disabled
			       v-model="state.form.role"
			       placeholder="请输入邀请人类型"
			       placeholder-class="placeholder-class"
			     />
			   </view>
			   <view class="form-item ss-flex justify-between align-center b-b-c">
			     <view class="form-label"> <text>*</text>邀请人姓名 </view>
			     <input
			       class="form-input"
			       disabled
			       v-model="state.form.agency_name"
			       placeholder="请输入邀请人姓名"
			       placeholder-class="placeholder-class"
			     />
			   </view>
			  <view class="form-item ss-flex justify-between align-center b-b-c">
			    <view class="form-label"> <text>*</text>邀请人手机号码 </view>
			    <input
			      class="form-input"
			      disabled
			      v-model="state.form.agency_mobile"
			      placeholder="请输入邀请人手机号码"
			      placeholder-class="placeholder-class"
			    />
			  </view>
		  </template>
		  
        <!-- 商户信息模块 -->
        <view class="form-title"> 商户信息 </view>
		<view class="form-item ss-flex justify-between align-center b-b-c">
		  <view class="form-label"> <text>*</text>身份 </view>
		  <radio-group  @change="radioChange($event,'identity')" class="ss-flex flex-wrap font-1"  style="width:370rpx;color:#424242">
			<label class="uni-list-cell uni-list-cell-pd ss-flex ss-m-l-10" v-for="(item, index) in radioList1" :key="item.value">
				<radio color="#003288"  style="transform: scale(0.5)" :value="item.value" :checked="state.form.identity == item.value" />
				<view class="font-1" style="color:gray">{{item.label}}</view>
			</label>
		</radio-group>
		</view>
        <view class="form-item ss-flex justify-between align-center b-b-c">
          <view class="form-label"> <text>*</text>商户名 </view>
          <input
            class="form-input"
            :disabled="state.disabled"
            v-model="state.form.merchant_name"
            placeholder="请输入营业执照上面的商户名称"
            placeholder-class="placeholder-class"
          />
        </view>
        <view class="form-item ss-flex justify-between align-center b-b-c">
          <view class="form-label"> <text>*</text>负责人 </view>
          <input
            class="form-input"
            :disabled="state.disabled"
            v-model="state.form.name"
            placeholder="请输入负责人姓名"
            placeholder-class="placeholder-class"
          />
        </view>
        <view class="form-item ss-flex justify-between align-center b-b-c">
          <view class="form-label"> <text>*</text>身份证 </view>
          <input
            class="form-input"
            :disabled="state.disabled"
            v-model="state.form.card_number"
            placeholder="请输入负责人身份证号"
            placeholder-class="placeholder-class"
          />
        </view>
		<view class="form-item ss-flex justify-between align-center b-b-c">
		  <view class="form-label"> <text>*</text>身份证有效期-起始 </view>
		  <uni-datetime-picker type="date" :clear-icon="false" v-model="state.form.idCardStart"/>
		</view>
		<view class="form-item  b-b-c">
			<view class="ss-flex justify-between ">
				<view class="form-label"> <text>*</text>身份证有效期-结束 </view>
				<radio-group  @change="radioChangeTime($event,'time1')" class="ss-flex flex-wrap font-1 ss-p-t-14"  style="width:370rpx;color:#424242">
					<label class="uni-list-cell uni-list-cell-pd ss-flex ss-m-l-10" v-for="(item, index) in radioList" :key="item.value">
							<radio color="#003288" :disabled="state.disabled" style="transform: scale(0.5)" :value="item.value" :checked="state.time1 == item.value" />
						<view class="font-1" style="color:gray">{{item.label}}</view>
					</label>
				</radio-group>
			</view>
				<uni-datetime-picker  v-if="state.time1==1" type="date" :clear-icon="false" v-model="state.form.idCardEnd" />
		</view>
        <view class="form-item ss-flex justify-between align-center b-b-c">
          <view class="form-label"> <text>*</text>手机 </view>
          <input
            class="form-input"
            :disabled="state.disabled"
            v-model="state.form.mobile"
            placeholder="请输入负责人手机号"
            placeholder-class="placeholder-class"
          />
        </view>
        <!-- <view class="form-item ss-flex justify-between align-center b-b-c">
          <view class="form-label"> <text>*</text>邮箱 </view>
          <input
            class="form-input"
            :disabled="state.disabled"
            v-model="state.form.email"
            placeholder="请输入负责人邮箱"
            placeholder-class="placeholder-class"
          />
        </view> -->
		<view class="form-item ss-flex justify-between align-center b-b-c">
		  <view class="form-label"> <text>*</text>客服电话</view>
		  <input
		    class="form-input"
		    :disabled="state.disabled"
		    v-model="state.form.kefu_tel"
		    type="number"
		    placeholder="请输入客服电话"
		    placeholder-class="placeholder-class"
		  />
		</view>
		<view class="form-item ss-flex justify-between align-center b-b-c" @tap="state.showMcc = true">
		  <view class="form-label"> <text>*</text>mcc行业类型 </view>
		 
		    <view class="uni-input">{{ state.mcc_name || '请选择行业类型' }}</view>
		</view>
        <view class="form-item ss-flex justify-between align-center b-b-c">
          <view class="form-label"> <text>*</text>企业名称 </view>
          <input
            class="form-input"
            :disabled="state.disabled"
            v-model="state.form.entity_name"
            placeholder="请输入企业名称"
            placeholder-class="placeholder-class"
          />
        </view>
        <view class="form-item ss-flex justify-between align-center b-b-c">
          <view class="form-label"> <text>*</text>社会信用代码 </view>
          <input
            class="form-input"
            :disabled="state.disabled"
            v-model="state.form.social_credit_code"
            placeholder="请输入社会信用代码"
            placeholder-class="placeholder-class"
          />
        </view>
        <!-- 收款账户模块 -->
        <view class="form-title"> 收款账户 </view>
		<view class="form-item ss-flex justify-between align-center b-b-c">
		  <view class="form-label"> <text>*</text>银行卡类型 </view>
		  <radio-group  @change="radioChange($event,'bank_type')" class="ss-flex flex-wrap font-1"  style="width:370rpx;color:#424242">
			<label class="uni-list-cell uni-list-cell-pd ss-flex ss-m-l-10" v-for="(item, index) in radioList2" :key="item.value">
				<radio color="#003288"  style="transform: scale(0.5)" :value="item.value" :checked="state.form.bank_type == item.value" />
				<view class="font-1" style="color:gray">{{item.label}}</view>
			</label>
		</radio-group>
		</view>
        <view class="form-item ss-flex justify-between align-center b-b-c" @tap="state.showBank = true">
          <view class="form-label"> <text>*</text>收款银行 </view>
         
            <view class="uni-input">{{ state.form.bank_name || '请选择收款银行' }}</view>
        </view>
        <view class="form-item ss-flex justify-between align-center b-b-c">
          <view class="form-label"> <text>*</text>开户总行编码 </view>
          <input
            class="form-input"
            :disabled="true"
            v-model="state.form.bank_code"
            placeholder="请输入开户总行编码"
            placeholder-class="placeholder-class"
          />
        </view>
        <view class="form-item ss-flex justify-between align-center b-b-c">
          <view class="form-label"> <text>*</text>收款户名 </view>
          <input
            class="form-input"
            :disabled="state.disabled"
            v-model="state.form.bank_receive_name"
            placeholder="请输入收款户名"
            placeholder-class="placeholder-class"
          />
        </view>
        <view class="form-item ss-flex justify-between align-center b-b-c">
          <view class="form-label"> <text>*</text>收款账号 </view>
          <input
            class="form-input"
            :disabled="state.disabled"
            v-model="state.form.bank_account"
            placeholder="请输入收款银行账号"
            placeholder-class="placeholder-class"
          />
        </view>
        <view class="form-item ss-flex justify-between align-center b-b-c">
          <view class="form-label"> <text>*</text>预留手机 </view>
          <input
            class="form-input"
            :disabled="state.disabled"
            v-model="state.form.bank_mobile"
            type="number"
            placeholder="请输入银行预留手机"
            placeholder-class="placeholder-class"
          />
        </view>
		
        <!-- 经营信息 -->
        <view class="form-title"> 经营信息 </view>
		<view class="form-item ss-flex justify-between align-center b-b-c">
		  <view class="form-label"> <text>*</text>营业执照有效期-起始 </view>
		  <uni-datetime-picker type="date" :clear-icon="false" v-model="state.form.licenseStart"/>
		</view>
		<view class="form-item  b-b-c">
			<view class="ss-flex justify-between ">
				<view class="form-label"> <text>*</text>营业执照有效期-结束  </view>
				<radio-group  @change="radioChangeTime($event,'time2')" class="ss-flex flex-wrap font-1 ss-p-t-14"  style="width:370rpx;color:#424242">
					<label class="uni-list-cell uni-list-cell-pd ss-flex ss-m-l-10" v-for="(item, index) in radioList" :key="item.value">
							<radio color="#003288" :disabled="state.disabled" style="transform: scale(0.5)" :value="item.value" :checked="state.time2 == item.value" />
						<view class="font-1" style="color:gray">{{item.label}}</view>
					</label>
				</radio-group>
			</view>
			<uni-datetime-picker v-if="state.time2==1" type="date" :clear-icon="false" v-model="state.form.licenseEnd" />
		</view>
		
        <view class="form-item ss-flex justify-between align-center b-b-c">
          <view class="form-label"> <text>*</text>企业所在地 </view>
          <view class="uni-list-cell-db" @click="state.showRegion = true">
            <uni-easyinput
              v-model="state.model.region"
              disabled
              :inputBorder="false"
              :styles="{ disableColor: '#fff', color: '#333' }"
              placeholderStyle="color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal"
              placeholder="请选择省-市-区"
            >
              <template v-slot:right>
                <uni-icons type="right"></uni-icons>
              </template>
            </uni-easyinput>
          </view>
        </view>
        <view class="form-item ss-flex justify-between align-center b-b-c">
          <view class="form-label"> <text>*</text>详细地址 </view>
          <input
            class="form-input"
            :disabled="state.disabled"
            v-model="state.form.address"
            placeholder="请输入详细地址"
            placeholder-class="placeholder-class"
          />
        </view>
        <view
          class="form-item ss-flex flex-column justify-between align-start ss-p-b-15 ss-m-t-15 b-b-c"
        >
          <view class="form-label"> <text>*</text>营业执照照片 </view>
          <view class="form-right ss-flex align-end">
            <view class="form-right-image" v-if="state.form.business_license">
              <image
                class="form-right-image-item"
                :src="sheep.$url.cdn(state.form.business_license)"
                mode="aspectFill"
              >
              </image>
              <view class="form-right-image-close" @click="deleteLicence" v-if="!state.disabled">
                <uni-icons type="clear" size="26"></uni-icons>
              </view>
            </view>
            <view
              class="form-right-add ss-flex justify-center align-center"
              @click="addLicence"
              v-else
            >
              <uni-icons type="plusempty" size="26" color="#979797"></uni-icons>
            </view>
          </view>
        </view>
        <view class="form-item ss-flex flex-column justify-between align-start ss-p-b-15 ss-m-t-15 b-b-c">
          <view class="form-label"> <text>*</text>负责人身份证国徽面 </view>
          <view class="form-right ss-flex align-end">
            <view class="form-right-image" v-if="state.form.reverse_card">
              <image
                class="form-right-image-item"
                :src="sheep.$url.cdn(state.form.reverse_card)"
                mode="aspectFill"
              >
              </image>
              <view class="form-right-image-close" @click="deleteBack" v-if="!state.disabled">
                <uni-icons type="clear" size="26"></uni-icons>
              </view>
            </view>
            <view
              class="form-right-add ss-flex justify-center align-center"
              @click="addBackImg"
              v-else
            >
              <uni-icons type="plusempty" size="26" color="#979797"></uni-icons>
            </view>
          </view>
        </view>
        <view
          class="form-item ss-flex flex-column justify-between align-start ss-p-b-15 ss-m-t-15 b-b-c"
        >
          <view class="form-label"> <text>*</text>负责人身份证人像面 </view>
          <view class="form-right ss-flex align-end">
            <view class="form-right-image" v-if="state.form.protrait_card">
              <image
                class="form-right-image-item"
                :src="sheep.$url.cdn(state.form.protrait_card)"
                mode="aspectFill"
              >
              </image>
              <view class="form-right-image-close" @click="deleteFont" v-if="!state.disabled">
                <uni-icons type="clear" size="26"></uni-icons>
              </view>
            </view>
            <view
              class="form-right-add ss-flex justify-center align-center"
              @click="addFontImg"
              v-else
            >
              <uni-icons type="plusempty" size="26" color="#979797"></uni-icons>
            </view>
          </view>
        </view>
        <view
          class="form-item ss-flex flex-column justify-between align-start ss-p-b-15 ss-m-t-15 b-b-c"
        >
          <view class="form-label"> <text>*</text>{{state.form.bank_type==1?'开户证明':'银行卡'}}</view>
          <view class="form-right ss-flex align-end">
            <view class="form-right-image" v-if="state.form.bank_card_image">
              <image
                class="form-right-image-item"
                :src="sheep.$url.cdn(state.form.bank_card_image)"
                mode="aspectFill"
              >
              </image>
              <view class="form-right-image-close" @click="deleteBankImg" v-if="!state.disabled">
                <uni-icons type="clear" size="26"></uni-icons>
              </view>
            </view>
            <view
              class="form-right-add ss-flex justify-center align-center"
              @click="addBankImg"
              v-else
            >
              <uni-icons type="plusempty" size="26" color="#979797"></uni-icons>
            </view>
          </view>
        </view>
		
		<view class="form-item ss-flex flex-column justify-between align-start ss-p-b-15 ss-m-t-15 b-b-c">
		  <view class="form-label"> <text>*</text>收银台图片 </view>
		  <view class="form-right ss-flex align-end">
		    <view class="form-right-image" v-if="state.form.cashierDeskPic">
		      <image
		        class="form-right-image-item"
		        :src="sheep.$url.cdn(state.form.cashierDeskPic)"
		        mode="aspectFill"
		      >
		      </image>
		      <view class="form-right-image-close" @click="deleteImg('cashierDeskPic')" v-if="!state.disabled">
		        <uni-icons type="clear" size="26"></uni-icons>
		      </view>
		    </view>
		    <view
		      class="form-right-add ss-flex justify-center align-center"
		      @click="addImg('cashierDeskPic')"
		      v-else
		    >
		      <uni-icons type="plusempty" size="26" color="#979797"></uni-icons>
		    </view>
		  </view>
		</view>
		
		<view class="form-item ss-flex flex-column justify-between align-start ss-p-b-15 ss-m-t-15 b-b-c">
		  <view class="form-label"> <text>*</text>门头照 </view>
		  <view class="form-right ss-flex align-end">
		    <view class="form-right-image" v-if="state.form.doorPic">
		      <image
		        class="form-right-image-item"
		        :src="sheep.$url.cdn(state.form.doorPic)"
		        mode="aspectFill"
		      >
		      </image>
		      <view class="form-right-image-close" @click="deleteImg('doorPic')" v-if="!state.disabled">
		        <uni-icons type="clear" size="26"></uni-icons>
		      </view>
		    </view>
		    <view
		      class="form-right-add ss-flex justify-center align-center"
		      @click="addImg('doorPic')"
		      v-else
		    >
		      <uni-icons type="plusempty" size="26" color="#979797"></uni-icons>
		    </view>
		  </view>
		</view>
		<view class="form-item ss-flex flex-column justify-between align-start ss-p-b-15 ss-m-t-15 b-b-c">
		  <view class="form-label"> <text>*</text>经营环境图片 </view>
		  <view class="form-right ss-flex align-end">
		    <view class="form-right-image" v-if="state.form.insidePic">
		      <image
		        class="form-right-image-item"
		        :src="sheep.$url.cdn(state.form.insidePic)"
		        mode="aspectFill"
		      >
		      </image>
		      <view class="form-right-image-close" @click="deleteImg('insidePic')" v-if="!state.disabled">
		        <uni-icons type="clear" size="26"></uni-icons>
		      </view>
		    </view>
		    <view
		      class="form-right-add ss-flex justify-center align-center"
		      @click="addImg('insidePic')"
		      v-else
		    >
		      <uni-icons type="plusempty" size="26" color="#979797"></uni-icons>
		    </view>
		  </view>
		</view>
		
        <view class="notion ss-m-t-15">
          以上所需上传文件格式为jpg、png格式，单张大小不能超过8M
        </view>
        <!-- 开票信息模块 -->
        <!-- <view class="form-title ss-m-t-15"> 开票信息 </view>
        <view class="form-item ss-flex justify-between align-center b-b-c">
          <view class="form-label"> <text>*</text>发票抬头 </view>
          <input
            class="form-input"
            :disabled="state.disabled"
            v-model="state.form.invoice_header"
            placeholder="请输入发票抬头"
            placeholder-class="placeholder-class"
          />
        </view>
        <view class="form-item ss-flex justify-between align-center b-b-c">
          <view class="form-label"> <text>*</text>税号 </view>
          <input
            class="form-input"
            :disabled="state.disabled"
            v-model="state.form.tax"
            placeholder="请输入税号"
            placeholder-class="placeholder-class"
          />
        </view> -->
      </view>
      <view
        style="width: 1rpx; height: 260rpx"
        v-if="state.status !== 2 || (state.status === 2 && !state.vipStatus)"
      ></view>
      <view class="bottom-box ss-safe-bottom" v-if="state.form.id == null">
        <view class="ss-p-y-20 ss-flex justify-center">
          <view class="btn-box" @click="handleConfirm">提交</view>
        </view>
      </view>
      <view
        class="bottom-box ss-safe-bottom"
        v-if="(state.form.sigin_link != null && state.status === 0) "
      >
        <view class="ss-p-y-20 ss-flex justify-center">
          <view class="btn-box" @click="towebview">去签约</view>
        </view>
      </view>

      <view
        class="bottom-box ss-safe-bottom"
        v-if="state.form.status  == 2"
      >
        <view class="ss-p-y-20 ss-flex justify-center">
          <view class="btn-box" @click="handleConfirm">重新提交</view>
        </view>
      </view>
    </template>
    <!-- 省市区弹窗 -->
    <su-region-picker
      :show="state.showRegion"
      @cancel="state.showRegion = false"
      @confirm="onRegionConfirm"
    >
    </su-region-picker>
	
	<bank-picker
	  :show="state.showBank"
	  @cancel="state.showBank = false"
	  @confirm="bindPickerChange"
	>
	</bank-picker>
	
	<mcc-picker
	  :show="state.showMcc"
	  @cancel="state.showMcc = false"
	  @confirm="bindPickerChange($event,'mcc')"
	>
	</mcc-picker>
	
	
	<!-- 微信小程序(审核) 手机号登录 -->
	<!-- <button
	  v-if="sheep.$platform.name === 'WechatMiniProgram'"
	  open-type="getPhoneNumber"
	  @getphonenumber="thirdLogin('wechat', $event)"
	  class="ss-reset-button auto-login-btn"
	>
	  <image
	    class="auto-login-img"
	    :src="sheep.$url.static('/static/img/shop/platform/phone.png')"
	  >
	  </image>
	</button> -->
	
	<!-- 公众号|App微信登录 -->
	<!-- <button
	  v-if="
	    ['WechatOfficialAccount', 'App'].includes(sheep.$platform.name) &&
	    sheep.$platform.isWechatInstalled &&
	    !isWeChatBrowser()
	  "
	  @tap="thirdLogin('wechat')"
	  class="ss-reset-button auto-login-btn"
	>
	  <image
	    class="auto-login-img"
	    :src="sheep.$url.static('/static/img/shop/platform/wechat.png')"
	  >
	  </image>
	</button> -->
	
	<!-- iOS登录 -->
	<!-- <button
	  v-if="sheep.$platform.os === 'ios' && sheep.$platform.name === 'App'"
	  @tap="thirdLogin('apple')"
	  class="ss-reset-button auto-login-btn"
	>
	  <image
	    class="auto-login-img"
	    :src="sheep.$url.static('/static/img/shop/platform/apple.png')"
	  >
	  </image>
	</button> -->
  </s-layout>
</template>

<script setup>
import { computed, reactive, ref } from 'vue';
import sheep from '@/sheep';
import { onLoad } from '@dcloudio/uni-app';
import { cloneDeep } from 'lodash';
import Test from '@/sheep/helper/test.js';
import bankPicker from '../components/bank-picker'
import mccPicker from '../components/mcc-picker'
import uniDatetimePicker from "../components/uni-datetime-picker/uni-datetime-picker.vue"
// #ifdef APP
import { showAuditModal } from '@/sheep/hooks/useAudit.js';
// #endif
const radioList=[
		{value:1,label:'选择日期'},
		{value:2,label:'永久有效'},
	];
const state = reactive({
	time1:1,
	time2:1,
	mcc_name:'',
	id:null,//表单id
	type:null,//0自己入驻，1代理入驻
  showRegion: false,
  showBank:false,
  showMcc:false,
  model: {
    consignee: '',
    mobile: '',
    address: '',
    is_default: false,
    region: '',
  },
  form: {
	  licenseStart:'',//营业执照有效期-结束
	  licenseEnd:'',//营业执照有效期-起始
	  idCardEnd:'',//身份证有效期-结束
	  idCardStart:'',//身份证有效期-起始
	  insidePic:'',//经营环境图片
	  doorPic:'',//门头照
	  cashierDeskPic:'',//收银台图片
	  mcc_code:'',//mcc
	  identity:1,
	  bank_type:1,
    entity_name: '',
    name: '',
    card_number: '',
    mobile: '',
    legal_person: '',
    merchant_name: '', //企业
    social_credit_code: '', //信用代码
    bank_code: '', //开户行
    bank_account: '', //
    bank_name: '', // 收款开户行
    bank_receive_name: '', //收款户名
    // province: '', //省
    // city: '', // 市
    // district: '', // 区
    bank_mobile: '', // 银行卡手机号
    // invoice_header: '', //发票抬头
    // tax: '', //税号
  },
  tagList: [],
  member: [
    {
      name: '',
      position: '',
      avatar: '',
    },
  ],
  status: null, // 0 未申请  1 申请中
  disabled: false,
  id: '',
  reason: '',
  vipStatus: false,
});
const areaArr = ref([]);
const bankArr = ref([]);
const radioList1=[
		{value:1,label:'企业资质'},
		{value:2,label:'个体户'},
		// {value:3,label:'个人'},//先不做
	]
const radioList2=[
	{value:1,label:'对公户'},
	{value:2,label:'银行卡'},
]

const onRegionConfirm = (e) => {
  state.model = {
    ...state.model,
    ...e,
  };
  state.model.region =
    state.model.province_name + '/' + state.model.city_name + '/' + e.district_name;
  state.showRegion = false;
  console.log(state.model, 'state.model');
};

// 选择银行
const bindPickerChange = (e,str) => {
	console.log(e)
	if(str=='mcc'){//选择mcc
		state.form.mcc_code = e.value;
		state.mcc_name = e.label;
		state.showMcc = false;
	}else{//选择银行
		state.form.bank_code = e.value;
		state.form.bank_name = e.label;
		state.showBank = false;
	}
  
  
};
function radioChangeTime(e,str){
		state[str]=e.detail.value
	}
function radioChange(e,str){
		state.form[str]=e.detail.value
	}
const withdraw = async () => {
  const { error, data } = await sheep.$api.resource.revoke({
    id: state.id,
    type: 'member',
  });

  if (error === 0) {
    uni.showToast({
      title: '撤销成功',
      duration: 1000,
      icon: 'none',
      success() {
        setTimeout(() => {
          uni.navigateBack();
        }, 1000);
      },
    });
  }
};
// 跳转h5页面
const towebview = () => {
  uni.navigateTo({
    url: '/pages/commission/merchant/webview?url=' + state.form.sigin_link,
  });
};
const handleConfirm = async () => {
  if (state.form.entity_name === '') {
    return uni.showToast({
      title: '请填写商户名',
      icon: 'none',
      duration: 1500,
    });
  }
  if (state.form.name === '') {
    return uni.showToast({
      title: '请填写负责人姓名',
      icon: 'none',
      duration: 1500,
    });
  }
  if (state.form.card_number === '') {
    return uni.showToast({
      title: '请填写负责人身份证',
      icon: 'none',
      duration: 1500,
    });
  }
  if (state.form.mobile === '') {
    return uni.showToast({
      title: '请填写负责人手机号',
      icon: 'none',
      duration: 1500,
    });
  }
  // if (state.form.email === '') {
  //   return uni.showToast({
  //     title: '请填写负责人邮箱',
  //     icon: 'none',
  //     duration: 1500,
  //   });
  // }
  if (state.form.social_credit_code === '') {
    return uni.showToast({
      title: '请填写社会信用代码',
      icon: 'none',
      duration: 1500,
    });
  }
  if (state.form.bank_code === '') {
    return uni.showToast({
      title: '请选择收款银行',
      icon: 'none',
      duration: 1500,
    });
  }
  if (state.form.mcc_code === '') {
    return uni.showToast({
      title: '请选择mcc行业类型',
      icon: 'none',
      duration: 1500,
    });
  }
  if (state.form.bank_account === '') {
    return uni.showToast({
      title: '请填写收款账号',
      icon: 'none',
      duration: 1500,
    });
  }
  if (state.form.bank_receive_name === '') {
    return uni.showToast({
      title: '请填写收款户名',
      icon: 'none',
      duration: 1500,
    });
  }
  if (state.form.bank_mobile === '') {
    return uni.showToast({
      title: '请填写银行预留手机',
      icon: 'none',
      duration: 1500,
    });
  }
  if (state.model.region === '') {
    return uni.showToast({
      title: '请选择企业所在地',
      icon: 'none',
      duration: 1500,
    });
  }
  if (state.form.address === '') {
    return uni.showToast({
      title: '请填写详细地址',
      icon: 'none',
      duration: 1500,
    });
  }
  // if (state.form.invoice_header === '') {
  //   return uni.showToast({
  //     title: '请填写发票抬头',
  //     icon: 'none',
  //     duration: 1500,
  //   });
  // }
  // if (state.form.tax === '') {
  //   return uni.showToast({
  //     title: '请填写税号',
  //     icon: 'none',
  //     duration: 1500,
  //   });
  // }

  if (!Test.mobile(state.form.mobile)) {
    return uni.showToast({
      title: '手机号格式错误',
      icon: 'none',
      duration: 1500,
    });
  }
  if (!state.model.province_id) {
    return uni.showToast({
      title: '请选择地区',
      icon: 'none',
      duration: 1500,
    });
  }

  state.form.province_city_area=state.model.province_id+'-'+state.model.city_id+'-'+state.model.district_id
  let submitForm = cloneDeep(state.form);
  if(state.time1==2){
	  submitForm.idCardEnd='长期'
  }
  if(state.time2==2){
  	  submitForm.licenseEnd='长期'
  }
  uni.showLoading()
  const { error, data } = state.form.status  != 2
  ?await sheep.$api.commission.merchant.applyAddTest({
	  ...submitForm,
	  serve:3,
	  type:2,//入驻 2进件
  }):await sheep.$api.commission.merchant.applyEditTest(submitForm.id,{
	  ...submitForm,
	  serve:3,
	  type:2,//入驻 2进件
  })

  if (error === 0) {
	  uni.hideLoading()
    uni.showToast({
      title: '提交成功,等待审核',
      icon: 'none',
      duration: 1500,
    });
    uni.setStorageSync('area', state.model.region);
    setTimeout(() => {
      uni.navigateBack({
		  delta: 1,
	  });
    }, 1500);
  }
};



const addBanner = () => {
  // #ifdef MP-WEIXIN
  uni.chooseMedia({
    count: 9,
    mediaType: ['image', 'video'],
    sourceType: ['album', 'camera'],
    maxDuration: 30,
    camera: 'back',
    success(res) {
      res.tempFiles.map(async (item) => {
        await requestBanner(item.tempFilePath);
      });
    },
  });
  // #endif
  // #ifdef APP
  showAuditModal(
    'WRITE_EXTERNAL_STORAGE',
    () => {
      uni.chooseImage({
        count: 9,
        sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
        sourceType: ['album'], //从相册选择
        async success(res) {
          res.tempFilePaths.map(async (item) => {
            await requestBanner(item);
          });
        },
      });
    },
    null,
    false,
  );
  // #endif
};

const requestBanner = async (url) => {
  const response = await sheep.$api.app.upload(url);
  state.form.banner.push(response.path);
};

const deleteBankImg = () => {
  state.form.bank_card_image = '';
};
const deleteLicence = () => {
  state.form.business_license = '';
};
const deleteFont = () => {
  state.form.protrait_card = '';
};
const deleteBack = () => {
	state.form.reverse_card = '';
};
const deleteImg= (str) => {
	state.form[str] = '';
};
const addLicence = () => {
  // #ifdef MP-WEIXIN
  uni.chooseImage({
    count: 1,
    sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
    sourceType: ['album'], //从相册选择
    async success(res) {
      const response = await sheep.$api.app.upload(res.tempFilePaths[0]);
      state.form.business_license = response.path;
    },
  });
  // #endif
  // #ifdef APP
  showAuditModal(
    'WRITE_EXTERNAL_STORAGE',
    () => {
      uni.chooseImage({
        count: 1,
        sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
        sourceType: ['album'], //从相册选择
        async success(res) {
          const response = await sheep.$api.app.upload(res.tempFilePaths[0]);
          state.form.business_license = response.path;
        },
      });
    },
    null,
    false,
  );
  // #endif
};
// 上传国徽面
const addBackImg = () => {
  // #ifdef MP-WEIXIN
  uni.chooseImage({
    count: 1,
    sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
    sourceType: ['album'], //从相册选择
    async success(res) {
      const response = await sheep.$api.app.upload(res.tempFilePaths[0]);
      state.form.reverse_card = response.path;
    },
  });
  // #endif
  // #ifdef APP
  showAuditModal(
    'WRITE_EXTERNAL_STORAGE',
    () => {
      uni.chooseImage({
        count: 1,
        sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
        sourceType: ['album'], //从相册选择
        async success(res) {
          const response = await sheep.$api.app.upload(res.tempFilePaths[0]);
          state.form.reverse_card = response.path;
        },
      });
    },
    null,
    false,
  );
  // #endif
};
const addFontImg = () => {
  // #ifdef MP-WEIXIN
  uni.chooseImage({
    count: 1,
    sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
    sourceType: ['album'], //从相册选择
    async success(res) {
      const response = await sheep.$api.app.upload(res.tempFilePaths[0]);
      state.form.protrait_card = response.path;
    },
  });
  // #endif
  // #ifdef APP
  showAuditModal(
    'WRITE_EXTERNAL_STORAGE',
    () => {
      uni.chooseImage({
        count: 1,
        sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
        sourceType: ['album'], //从相册选择
        async success(res) {
          const response = await sheep.$api.app.upload(res.tempFilePaths[0]);
          state.form.protrait_card = response.path;
        },
      });
    },
    null,
    false,
  );
  // #endif
};
const addBankImg = () => {
  // #ifdef MP-WEIXIN
  uni.chooseImage({
    count: 1,
    sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
    sourceType: ['album'], //从相册选择
    async success(res) {
      const response = await sheep.$api.app.upload(res.tempFilePaths[0]);
      state.form.bank_card_image = response.path;
    },
  });
  // #endif
  // #ifdef APP
  showAuditModal(
    'WRITE_EXTERNAL_STORAGE',
    () => {
      uni.chooseImage({
        count: 1,
        sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
        sourceType: ['album'], //从相册选择
        async success(res) {
          const response = await sheep.$api.app.upload(res.tempFilePaths[0]);
          state.form.bank_card_image = response.path;
        },
      });
    },
    null,
    false,
  );
  // #endif
};

const addImg = (str) => {
  // #ifdef MP-WEIXIN
  uni.chooseImage({
    count: 1,
    sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
    sourceType: ['album'], //从相册选择
    async success(res) {
      const response = await sheep.$api.app.upload(res.tempFilePaths[0]);
      state.form[str] = response.path;
    },
  });
  // #endif
  // #ifdef APP
  showAuditModal(
    'WRITE_EXTERNAL_STORAGE',
    () => {
      uni.chooseImage({
        count: 1,
        sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
        sourceType: ['album'], //从相册选择
        async success(res) {
          const response = await sheep.$api.app.upload(res.tempFilePaths[0]);
          state.form[str] = response.path;
        },
      });
    },
    null,
    false,
  );
  // #endif
};
// 获取代理人信息
async function getInfo(){
		const res =await sheep.$api.commission.giveaway.getUserInfo()
		state.form.agency_name=res.data?.name
		state.form.agency_mobile=res.data?.phone
		state.form.role = sheep.$store('user').userInfo.role;
		// if(!state.form.agency_name){
		// 	uni.showToast({
		// 		title: '请先前往填写资料',
		// 		icon: 'none',
		// 		duration: 4000
		// 	})
		// }
		
	}



// 第三方授权登陆
const thirdLogin = async (provider, event = null) => {

  // const invite_code = uni.getStorageSync('invite_code');
  console.log(event);

  // if (invite_code) {
  //   //绑定邀请码
  //   let res = await sheep.$api.tuangou.bind({ invite_code });
  //   if (res) {
  //     console.log(res);
  //     uni.removeStorageSync('invite_code');
  //   }
  // }

  // if (!state.protocol) {
  //   sheep.$helper.toast('请勾选同意');
  //   return;
  // }
  // const loginRes = await sheep.$platform.useProvider(provider).login(event?.detail || null);

  // if (loginRes) {
  //   closeAuthModal();
  //   const userInfo = await sheep.$store('user').getInfo();
  // }
};




onLoad(async (options) => {
	console.log('options',options)
	
	state.type=options.type
	state.id=options.id
	// 不知道能不能帮别人入驻
	if(options.type==='1'){//代理入驻
		if(options.id){
			await getCheckInDet(options.id);
		}
		//获取bd填写资料信息
		await getInfo()
	}else{
		// 自己入驻查看历史提交信息
		await getCheckInDet(0);
	}
	
	
	
	
});

const getMccList3 = async (mccCode) => {
	  const res =await sheep.$api.commission.merchant.mccList({
		  mccCode
	  })
	  state.mcc_name=res.data[0].mccText
	}
// 获取用户详情
const getCheckInDet = async (id) => {
  const { error, data } = await sheep.$api.commission.merchant.applyDetailTest(id);

  if (data !== null) {
    state.status = data.status;
    state.form = data;
    if(state.form.idCardEnd=='长期'){
		state.time1=2
		state.form.idCardEnd=''
	}
	if(state.form.licenseEnd=='长期'){
		state.time2=2
		state.form.licenseEnd=''
	}
	if(state.form.mcc_code){
		await getMccList3(state.form.mcc_code)
	}
  }

  
  bankArr.value.forEach((el, index) => {
    if (el.value === data.bank_code) {
      state.form.bank_code = el.value;
      state.form.bank_name = el.label;
    }
  });
};


</script>

<style scoped lang="scss">
view {
  box-sizing: border-box;
}
image{
	flex-shrink:0
}

:deep()picker-view-column .picketText{
    line-height: 60rpx;
    height: 120rpx !important;
    overflow: auto;
    text-align: center;
    color: #000;
}
                        
.form-title {
  background: #d8d8d8;
  width: 100%;
  padding: 22rpx 40rpx;
}

.notion {
  color: #8d8d8d;
  font-size: 24rpx;
  padding: 15rpx 42rpx;
}
.ss-p-b-15 {
  padding-bottom: 15rpx !important;
}
.form-item {
  min-height: 100rpx;
  padding: 0 32rpx;
  .form-label {
    font-weight: 400;
    font-size: 28rpx;
    color: #000000;

    text {
      color: rgba(245, 43, 43, 0.85);
    }
  }

  .form-input {
    flex: 1;
    height: 100rpx;
    font-weight: 400;
    font-size: 28rpx;
    line-height: 100rpx;
    text-align: right;
  }

  .form-textarea {
    width: 686rpx;
    height: 202rpx;
    background: #f2f2f2;
    border-radius: 8rpx;
    font-weight: 400;
    font-size: 28rpx;
    padding: 16rpx 32rpx;
    box-sizing: border-box;
    margin-top: 12rpx;
  }

  .form-right {
    margin-top: 16rpx;

    .form-right-add {
      width: 178rpx;
      height: 178rpx;
      background: #e8e8e8;
      border-radius: 18rpx;
    }

    .form-right-tips {
      font-weight: 400;
      font-size: 24rpx;
      color: #999999;
      margin-left: 30rpx;
    }

    .form-right-image {
      width: 178rpx;
      height: 178rpx;
      position: relative;

      .form-right-image-item {
        width: 178rpx;
        height: 178rpx;
        border-radius: 18rpx;
      }
    }

    .form-right-image-close {
      position: absolute;
      right: -24rpx;
      top: -24rpx;
    }
  }

  .form-list {
    .list-item {
      width: 136rpx;
      height: 54rpx;
      border: 2rpx solid #999999;
      font-weight: 500;
      font-size: 24rpx;
      color: #999999;
      line-height: 54rpx;
      text-align: center;
      margin: 0 16rpx 18rpx 0;
    }
  }
}

.add-btn {
  width: 144rpx;
  height: 64rpx;
  border-radius: 16rpx;
  border: 2rpx solid #1677fe;
  font-weight: 500;
  font-size: 28rpx;
  color: #1677fe;
  line-height: 64rpx;
  text-align: center;
}

.bottom-box {
  width: 100%;
  position: fixed;
  left: 0;
  bottom: 0;
  z-index: 10;
  background-color: #fff;

  .btn-box {
    width: 686rpx;
    height: 88rpx;
    background: #1677fe;
    border-radius: 44rpx;
    font-weight: 500;
    font-size: 28rpx;
    color: #ffffff;
    line-height: 88rpx;
    text-align: center;
	position:relative;
  }

  .btn-withdraw {
    width: 686rpx;
    height: 88rpx;
    background: #dddddd;
    border-radius: 44rpx;
    font-weight: 500;
    font-size: 28rpx;
    color: #000000;
    line-height: 88rpx;
    text-align: center;
  }
}

.b-b-c {
  border-bottom: 1rpx solid #e0e0e0;
}

.placeholder-class {
  font-weight: 400;
  font-size: 28rpx;
  color: #cecece;
}

.active {
  border-color: #1677fe !important;
  color: #1677fe !important;
}

.status {
  width: 100%;

  .status-top {
    width: 100%;
    height: 130rpx;
    background-color: #fff;

    .status-wait {
      width: 100%;
      height: 130rpx;

      .status-wait-image {
        width: 64rpx;
        height: 64rpx;
      }

      .status-wait-title {
        font-weight: 500;
        font-size: 32rpx;
        color: #3d3d3d;
      }

      .status-wait-tips {
        font-weight: 500;
        font-size: 24rpx;
        color: #999999;
      }
    }
  }

  .status-bottom {
    width: 100%;
    height: 16rpx;
    background: #f3f3f3;
  }
}
</style>